import { http } from "@/utils/http";
import type { LoginTokenResult, userInfoType } from "@/store/utils";
/** svg验证码 */
export const getVerifyCode = () => {
  return http.request<any>("get", "/api/public/v1/captcha");
};

/** 登录 */
export const getLogin = (data?: object) => {
  return http.request<LoginTokenResult>("post", "/api/public/v1/login", {
    data
  });
};

/** 刷新`token` */
export const refreshTokenApi = (data?: object) => {
  return http.request<LoginTokenResult>("post", "/api/public/v1/login/token", {
    data
  });
};

/** 账户设置-个人信息 */
export const getInfo = () => {
  return http.request<userInfoType>("get", "/api/private/user/info");
};
/** 修改个人信息 */
export const updateInfo = (data?: object) => {
  return http.request<any>("post", "/api/private/user/info/edit", { data });
};

/** 获取验证码 */
export const getCode = (type: number | string, value: string) => {
  return http.request<any>("get", "/api/private/user/getCode", {
    params: { type, value }
  });
};
/** 修改电话或邮箱 */
export const updatePhoneOrEmail = (data?: object) => {
  return http.request<any>("post", "/api/private/user/editValue", {
    data
  });
};
/** 修改密码 */
export const updatePassword = (data?: object) => {
  return http.request<any>("post", "/api/private/user/editPwd", { data });
};
